{include file='common/head' /}
<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="name"  placeholder="会员名称" autocomplete="off" class="layui-input" value="{$get.name|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="uid"  placeholder="会员ID" autocomplete="off" class="layui-input" value="{$get.uid|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="tel"  placeholder="会员手机" autocomplete="off" class="layui-input" value="{$get.tel|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    <span style="line-height:40px;float: right;">共有数据：{$count} 条</span>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th style="text-align: center;">会员ID</th>
                            <th style="text-align: center;">会员名</th>
                            <th style="text-align: center;">手机号</th>
                            <th style="text-align: center;">下线客户数量</th>
                            <th style="text-align: center;">客户下单数</th>
                            <th style="text-align: center;">客户订单金额</th>
                            <th style="text-align: center;">注册时间</th>
                            <th style="text-align: center;">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="list" id="v"}
                        <tr>
                            <td style="text-align: center;">{$v.id}</td>
                            <td style="text-align: center;">{$v.name}</td>
                            <td style="text-align: center;">{$v.tel}</td>
                            <td style="text-align: center;">{$v.invite_num}</td>
                            <td style="text-align: center;">{$v.order_num}</td>
                            <td style="text-align: center;">{$v.order_total}元</td>
                            <td style="text-align: center;">{:date('Y-m-d H:i:s',$v['add_time'])}</td>
                            <td style="text-align: center;">
                                <button class="layui-btn-danger layui-btn layui-btn-xs" title="解除关系" onclick="member_del(this,{$v['id']})" href="javascript:;">
                                    <i class="layui-icon">&#xe640;</i>解除关系
                                </button>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['form','laydate'], function(){
        var laydate = layui.laydate;
        var  form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });

        // 监听全选
        form.on('checkbox(checkall)', function(data){
            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
    /*删除*/
    function member_del(obj,id){
        layer.confirm('确认解除此会员的推荐关系吗？',function(index){
            $.ajax({
                url:"{:url('Users/invite_del')}",
                type: "post",
                data:{id:id},
                dataType:"json",
                success:function (res) {
                    if(res.code == 200){
                        layer.msg(res.msg, {icon: 1,time:1000});
                        $(obj).parents("tr").remove();
                    }else{
                        layer.alert(res.msg, {icon:2,time:1000});
                    }
                },
                error:function(e){
                    layer.alert("网络错误", {icon:5,time:1000});
                },
            });
        });
    }
</script>
{include file='common/footer' /}